<template>
  <div>
    <h1>中标标书</h1>
    <br>
    <!--下拉列表-->
    <!--placeholder 提示信息-->
<!--    <el-select v-model="supplier" placeholder="请选择供应商">
      <el-option
          v-for="item in lessonArray"
          :key="item.supplierPkId"
          :label="item.supplierName"
          :value="item.supplierName">
      </el-option>
    </el-select>-->



    <el-row>
      <el-table :data="goodsList" stripe>
        <el-table-column prop="contractNumber" label="合同编号"></el-table-column>

        <el-table-column prop="priceNumber" label="报价书编号"></el-table-column>

        <el-table-column prop="supplierNumber" label="供应商编号"></el-table-column>
        <el-table-column prop="suppllierName" label="供应商名称"></el-table-column>

        <el-table-column prop="goodsNumber" label="商品编号"></el-table-column>
        <el-table-column label="商品规格" prop="goodsDetail"></el-table-column>
        <el-table-column label="单个报价" prop="goodsSellPrice"></el-table-column>
        <el-table-column label="商品名字" prop="goodsName"></el-table-column>
        <el-table-column label="商品类型" prop="goodsType"></el-table-column>
        <el-table-column label="合同总价" prop="contractTotalPrice"></el-table-column>
        <el-table-column label="商品数量" prop="goodsNum"></el-table-column>

        <el-table-column label="供货订单是否已提交" prop="status">
          <template #default="scope">
            {{ this.covertStatus(scope.row.status) }}
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template #default="scope">
            <el-button type="primary" v-if="scope.row.status===1" @click="view(scope.row)">供货订单提交</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination v-model:current-page="curPage" v-model:page-size="pageSize"
                     background :total="total" @current-change="changeCurPage()"></el-pagination>
    </el-row>
    <br>

  </div>
</template>

<script>
import servicePath from "../serviceConfig";
import axios from "axios";
import {ElMessage} from "element-plus";

export default {
  name: "PurchaseReceipt",
  created() {
    this.query();



  },
  data() {
    return {
      curPage: 1,
      pageSize: 3,
      total: 0,
      goodsList:[],
      supplier: '',
      add: false,
      userName: '',
      formlist: false,

      lessonArray: [],



      forms:{},
      imageUrl: '',
      commodityName: '',


    }

  }, methods: {
    covertStatus(statusCode) {


      if (statusCode === 1) {
        return '未提交'
      }
      if (statusCode === 2) {
        return '已提交'
      }
      if (statusCode === 3) {
        return '已付款'
      }
    },
    view(scope){
      axios.post("/apf/successfulinfo/supplyOrder",scope,{
        'headers': {'token': localStorage.getItem("token")}
      }).then(res=>{
        this.query();
      })

    },
    queryInventory() {
      let param = new URLSearchParams();
      param.append("commoditySerialNumber", this.form.commoditySerialNumber)
      axios.post("/api/CommodityRepertory/queryInventory", param).then(res => {
        if (res.data != null && "" != res.data) {

          this.form = res.data
          this.forms = res.data
          console.log(this.form)
          this.imageUrl=servicePath+res.data.img
          this.formlist = true

        } else {
          this.formlist = false
        }

      })


    }, change(scope) {
      axios.post("/api/shopping/update", scope).then(res => {

      })


    }, changePurchasePrice(scope) {
      axios.post("/api/shopping/update", scope).then(res => {

      })
    },

    addSQE() {
      this.add = true
    },
    removeItem(id) {
      let param = new URLSearchParams();
      param.append("id", id)

      axios.post("/api/shopping/deleteById", param).then(res => {
        this.query();
      })


    },
    addSupplier() {

      let param = {
        'supplierName': this.supplier,
        'commoditySerialNumber': this.form.commoditySerialNumber,
        'commodityName': this.form.commodityName,
        'brand': this.form.brand,
        'category': this.form.category,
        'amount': this.form.amount,
        'purchasePrice':this.forms.purchasePrice,
        'img': this.img,


      }

      if (this.imageUrl != null && "" != this.imageUrl) {
        axios.post("/api/shopping/add", param).then(res => {
          this.add = false
          this.formlist = false
          this.query();
          this.forms = {}
          this.form = {}

        })
      } else {
        ElMessage({
          message: '请选择照片',
          type: 'success'
        })
      }
      this.query();
      this.forms = {}
      this.imageUrl = '';


    },
    handleAvatarSuccess(res) {

      this.imageUrl = servicePath + res;
      this.img = res

    },
    PutInStorage() {
      let param = new URLSearchParams()
      param.append('SupplierName', this.supplier)

      if (this.supplier != null && '' != this.supplier) {
        if (this.goodsList != null) {
          axios.post("/api/shopping/putInStorage", param).then(res => {
            this.query();
          })
        } else {
          ElMessage({
            message: '未添加商品',
            type: 'success'
          })
        }

      } else {
        ElMessage({
          message: '请选择供应商',
          type: 'success'
        })
      }


    },
    query() {
      axios.post("/apf/successfulinfo/selectSuccessfulInfo", null,{
        'headers': {'token': localStorage.getItem("token")}
      }).then(res => {

        this.goodsList= res.data
        console.log(res.data)
        console.log(this.goodsList)

      })
    }
  }
}
</script>

<style scoped>

</style>